﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="APMS.WebSite.Views.User.Login" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <script type="text/javascript" language="javascript" src="../../Content/Scripts/jquery-1.2.6.min.js"></script>

    <%-- Main Script for this View--%>
    <script type="text/javascript" language="javascript">
        $(document).ready(function(){
            setupElements();
        });

        function setupElements() {
            $('#userName').focus(function() {
	            updateMessage('Type in your Username');
            });
            $('#password').focus(function() {
	            updateMessage('Type in your Password');
            });
            $('#rememberMe').focus(function() {
	            updateMessage('Check to skip login page next time.');
            });
            /*$('#loginButton').click(function() {
	            pageSubmit();
	            return false; // prevent page sumit - use page submit to post
            });*/
        }

        function updateMessage(msg) {
            if($('#errorMsg')) {
                $('#errorMsg').fadeOut('slow');
            }
        
            $('#instruction').html(msg);
        }

        function restoreOriginalMessage() {
            $('#instruction').text('Login to the system');
        }

        /*Not use for now*/
        function pageSubmit() {
            $.post("/User/Login", {
	            userName: $('#userName').attr('value'), 
	            password: $('#password').attr('value'), 
	            rememberMe: $('#rememberMe').attr('checked')
            }, function(errorMsg){
	            alert(errorMsg);
            });
        }
    </script>

    <%-- Inline styles to avoid unauthenticated request --%>
    <style media="screen" type="text/css">
        body
        {
            background-color: #005187;
            color: #000000;
            font-family: "Lucida Grande" ,Verdana, "Bitstream Vera Sans" ,Arial,sans-serif;
            font-size: 12px;
            line-height: 18px;
        }
        #errorMsg
        {
            background-color: Red;
            border: 1px solid #ccc;
            color: #FFF;
            padding: 3px;
            text-align: center;
        }
        #mainPanel
        {
        	-moz-border-radius: 5px;
            background-color: #E4F2FD;
            border: 10px solid #CCCCCC;
            margin: 50px auto;
            padding: 20px;
            width: 400px;
        }
        #mainPanel h1
        {
            font-size: 16px;
            margin: 0px 0px 20px;
        }
        #instruction
        {
            color: #A0A0A0;
        }
        #mainPanel label
        {
            display: block;
            font-size: 12px;
            font-weight: bold;
            margin: 0px 0px 2px;
        }
        #mainPanel input
        {
            display: block;
            color: #555555;
            font-size: 14px;
            padding: 3px;
            margin-bottom: 10px;
            width: 275px;
        }
        #mainPanel input.button
        {
            color: #000000;
            font-size: 14px;
            width: auto;
        }
        #mainPanel div.extra
        {
            border-top: 1px dashed #999999;
            margin-top: 20px;
            padding-top: 10px;
        }
        #mainPanel div.extra ul
        {
            margin: 0px 0px 0px 15px;
            padding: 0px;
        }
        #mainPanel div.extra li
        {
            list-style-type: square;
            padding: 3px 0px;
        }
    </style>
    <title>Login to APMS</title>
</head>
<body>
    <div id="container">
    
		<form method="post" action="/User/Login">
		
		<%if(ViewData.ContainsKey(UserController.KEY_ERROR_MSG)) { %>
		    <p id="errorMsg"><%=ViewData[UserController.KEY_ERROR_MSG] %></p>
	    <%} %>
	    
        <div id="mainPanel">
			<h1>Welcome to APMS</h1>
			<p id="instruction">Login to the system</p>
			<label for="userName">Username</label>
            <%=Html.TextBox("userName") %>
			<label for="password">Password</label>
            <%=Html.Password("password") %>
			<label style="font-weight:normal;">
				<input type="checkbox" id="rememberMe" name="rememberMe" style="display:inline; width:auto;" value="true" />
				Remember me on next login
			</label>
            <input id="loginButton" type="submit" class="button" value="Sign in" />
            <div class="extra">
				<ul>
					<li>
						<strong>Register: </strong> Don't have an account yet? <%=Html.ActionLink<UserController>(x => x.Create(), "Create One") %>
					</li>
					<li>
						<strong>Help: </strong><a href="#">Forgot Password</a>
					</li>
				</ul>
			</div>
        </div>
		</form>
		
    </div>
</body>
</html>
